package com.flower.auth.controller;

import com.flower.auth.common.entity.Result;
import com.flower.auth.convert.AuthPermissionDTOConverter;
import com.flower.auth.convert.AuthRolePermissionDTOConverter;
import com.flower.auth.dto.AuthPermissionDTO;
import com.flower.auth.dto.AuthRolePermissionDTO;
import com.flower.auth.dto.AuthUserDTO;
import com.flower.domain.entity.AuthPermissionBO;
import com.flower.domain.entity.AuthRolePermissionBO;
import com.flower.domain.service.AuthPermissionDomainService;
import com.flower.domain.service.AuthRolePermissionDomainService;
import com.google.common.base.Preconditions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-16 18:44
 */
@RestController
@RequestMapping("/rolePermission/")
@Slf4j
public class RolePermissionController {


    @Resource
    private AuthRolePermissionDomainService authRolePermissionDomainService;

    /**
     * 新增角色 权限 关联关系
     * @param authPermissionDTO
     * @return
     */
    @RequestMapping("add")
    public Result<Boolean> register(@RequestBody AuthRolePermissionDTO authPermissionDTO){

        Preconditions.checkArgument(!CollectionUtils.isEmpty(authPermissionDTO.getPermissionIds()),"权限关联不能为空");


        AuthRolePermissionBO authRolePermissionBO = AuthRolePermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);

        Boolean register = authRolePermissionDomainService.add(authRolePermissionBO);


        return Result.ok();
    }


//    @RequestMapping("update")
//    public Result<Boolean> update(@RequestBody AuthPermissionDTO authPermissionDTO){
//
//
//        AuthPermissionBO authPermissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);
//
//        authPermissionDomainService.update(authPermissionBO);
//
//        return Result.ok();
//    }
//
//
//    @RequestMapping("delete")
//    public Result<Boolean> delete(@RequestBody AuthPermissionDTO authPermissionDTO){
//
//
//        AuthPermissionBO authPermissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);
//
//
//        Boolean delete = authPermissionDomainService.delete(authPermissionBO);
//
//        return Result.ok(delete);
//    }


    @RequestMapping("changeStatus")
    public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO){






        return Result.ok();
    }


}
